package com.whut.whw.util;

import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.widget.ImageView;

import com.bumptech.glide.request.target.BitmapImageViewTarget;

/**
 * <pre>
 *  desc: Glide加载圆形图片
 *  Created by 忘尘无憾 on 2017/06/08.
 *  version:
 * </pre>
 */
public class GlideCircularLoadUtils extends BitmapImageViewTarget {
    private Context context;

    public GlideCircularLoadUtils(Context context, ImageView view) {
        super(view);
        this.context = context;
    }

    @Override
    protected void setResource(Bitmap resource) {
        RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource);
        circularBitmapDrawable.setCircular(true);
        view.setImageDrawable(circularBitmapDrawable);
    }
}
